<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="component/heard :: head"></head>
<body>
<nav th:include="component/nav :: nav"></nav>
<div class="container-flux">
    <div class="row ">
        <div class="col-4">
            <div class="card">
                <div class="card-body">
                    <h5>LSession</h5>
                    <div class="input-group mb-3">
                        <button id="session-create-btn" class="btn btn-outline-secondary" type="button">初始化</button>
                        <input id="session-id-ipt" type="text" class="form-control">
                        <button id="session-get-btn" class="btn btn-outline-secondary" type="button">获取</button>
                        <button id="session-del-btn" class="btn btn-outline-secondary" type="button">删除</button>
                    </div>
                    <div class="mb-3">
                        <textarea readonly id="session-info-text" class="form-control" rows="3"></textarea>
                    </div>
                    <div class="row">
                        <button id="session-saveCookie-btn" class="btn btn-outline-secondary" type="button">保存Cookie
                        </button>
                    </div>
                </div>

            </div>
        </div>
        <div class="col-4">
            <div class="card">
                <div class="card-body">
                    <h5>LenovoId</h5>
                    <div class="input-group mb-3">
                        <input id="lenovoid-username-ipt" value="978880162@qq.com" type="text" class="form-control">
                        <input id="lenovoid-password-ipt" value="1q2w3e4r" type="text" class="form-control">
                        <button id="lenovoid-login-btn" class="btn btn-outline-secondary" type="button">获取Token</button>
                    </div>
                    <div class="mb-3">
                        <textarea readonly id="lenovoid-info-text" class="form-control" rows="3"></textarea>
                    </div>
                    <div class="input-group mb-3">
                        <input id="lenovoid-token-ipt" value="" type="text" class="form-control">
                        <button id="lenovoid-account-btn" class="btn btn-outline-secondary" type="button">获取Account
                        </button>
                        <button id="lenovoid-user-btn" class="btn btn-outline-secondary" type="button">获取UserInfo
                        </button>
                    </div>
                    <div class="row">
                        <div class="col-6"><textarea readonly id="lenovoid-account-text" class="form-control"
                                                     rows="3"></textarea></div>
                        <div class="col-6"><textarea readonly id="lenovoid-user-text" class="form-control"
                                                     rows="3"></textarea></div>
                    </div>

                </div>
            </div>
        </div>
        <div class="col-4">
            <div class="card">
                <div class="card-body">
                    <h5>Online-Token</h5>
                    <div class="input-group mb-3">
                        <input id="ol-name" type="text" class="form-control">
                        <input id="ol-psw" type="text" class="form-control" value="1q2w3e4r">

                        <button id="ol-btn" class="btn btn-outline-secondary" type="button">获取</button>
                    </div>
                    <div class="mb-3">
                        <textarea id="ol-txt" readonly class="form-control" rows="3"></textarea>
                    </div>

                </div>

            </div>
        </div>
    </div>
</div>


</div>
</body>
<script>
    $(function () {
        let $sessionCreateBtn = $("#session-create-btn");
        let $sessionGetBtn = $("#session-get-btn");
        let $sessionDelBtn = $("#session-del-btn");
        let $sessionIdIpt = $("#session-id-ipt");
        let $sessionInfoText = $("#session-info-text");

        $sessionCreateBtn.on("click", function () {
            $.ajax({
                type: "PUT",
                url: "/session/create",
                success: function (msg) {
                    $sessionIdIpt.val(msg);
                }
            });

        });
        $sessionGetBtn.on("click", function () {
            let sessionId = $sessionIdIpt.val();
            let url = /session/ + sessionId;
            $.ajax({
                type: "GET",
                url: url,
                success: function (msg) {
                    $sessionInfoText.text(msg);
                }
            });

        });
        $sessionDelBtn.on("click", function () {
            let sessionId = $sessionIdIpt.val();
            let url = /session/ + sessionId;
            $.ajax({
                type: "DELETE",
                url: url,
                success: function (msg) {
                    $sessionInfoText.text(msg);
                }
            });
        });

    });

    $(function () {
        let $username = $("#lenovoid-username-ipt");
        let $password = $("#lenovoid-password-ipt");
        let $info = $("#lenovoid-info-text");
        let $login = $("#lenovoid-login-btn");
        $login.on("click", function () {
            let username = $username.val();
            let password = $password.val();
            let url = '/lenovo/' + username + "/" + password;
            $.ajax({
                type: "GET",
                url: url,
                success: function (msg) {
                    $info.text(msg);
                    //console.log(msg);
                }
            });
        });


        let $lpsust = $("#lenovoid-token-ipt");
        let $getid = $("#lenovoid-account-btn");
        let $getUserInfo = $("#lenovoid-user-btn");
        let $account = $("#lenovoid-account-text");
        let $user = $("#lenovoid-user-text");


        $getid.on("click", function () {
            let lpsust = $lpsust.val();
            let url = '/lenovo/token/account/' + lpsust;
            $.ajax({
                type: "GET",
                url: url,
                success: function (msg) {
                    $account.text(msg);
                }
            });
        });
        $getUserInfo.on("click", function () {
            let lpsust = $lpsust.val();
            let url = '/lenovo/token/user/' + lpsust;
            $.ajax({
                type: "GET",
                url: url,
                success: function (msg) {
                    $user.text(msg);
                }
            });
        });
    });

    $(function () {
        let $username = $("#ol-name");
        let $password = $("#ol-psw");
        let $info = $("#ol-txt");
        let $btn = $("#ol-btn");
        $btn.on("click", function () {
            let username = $username.val();
            let password = $password.val();
            let url = '/mobile/auth';
            $.ajax({
                type: "GET",
                data: {"username": username, "password": password},
                url: url,
                success: function (msg) {
                    $info.text(msg);
                    //console.log(msg);
                }
            });
        });


        let $lpsust = $("#lenovoid-token-ipt");
        let $getid = $("#lenovoid-account-btn");
        let $getUserInfo = $("#lenovoid-user-btn");
        let $account = $("#lenovoid-account-text");
        let $user = $("#lenovoid-user-text");


        $getid.on("click", function () {
            let lpsust = $lpsust.val();
            let url = '/lenovo/token/account/' + lpsust;
            $.ajax({
                type: "GET",
                url: url,
                success: function (msg) {
                    $account.text(msg);
                }
            });
        });
        $getUserInfo.on("click", function () {
            let lpsust = $lpsust.val();
            let url = '/lenovo/token/user/' + lpsust;
            $.ajax({
                type: "GET",
                url: url,
                success: function (msg) {
                    $user.text(msg);
                }
            });
        });
    });
</script>
</html>
